from selenium import webdriver
import time,pytest
from Rk.zk9_29.Page import Page
from Rk.zk9_29.Page1 import Page1
from Rk.zk9_29.Page2 import Page2
import yaml




@pytest.fixture(scope='function')
def read():
    with open('A3mall.yaml','w',encoding='utf-8') as f:
            return yaml.safe_load(f)

a = read()

def driver():
    #打开浏览器
    driver = webdriver.Edge()
    driver.get('http://10.59.9.14:7003/')
    #窗口最大化
    driver.maximize_window()
    #隐式等待
    driver.implicitly_wait(10)

    yield  driver
    time.sleep(5)
    driver.quit()
def test_A3mall_001(driver):
    po = Page(driver)
    po.login()
    print(po.dy1())
    po.username()
    po.password()
    time.sleep(10)
    po.loginbuttn()
    po.souye()
    po.srk()
    po.souyebuttn()
    time.sleep(3)
    print(po.dy2())
    po.gwc()
def test_A3mall_002(driver):
    po1 = Page1(driver)
    po1.login()
    print(po1.dy1())
    po1.username()
    po1.password()
    time.sleep(10)
    po1.loginbuttn()
    po1.souye()
    po1.sp()
    po1.gwc()
    po1.ck()
@pytest.mark.parametrize('A3mall',a)
def test_A3mall_003(driver,A3mall):
    po2 = Page2(driver)
    po2.login()
    po2.username(username=A3mall.get('username'))
    po2.password(password=A3mall.get('password'))
    time.sleep(10)
    po2.loginbuttn()
